package com.loukou.lkt.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.loukou.lkt.lkt.bo.GoodsBo;
import com.loukou.lkt.lkt.bo.PageList;
import com.loukou.lkt.lkt.bo.SupplierBo;
import com.loukou.lkt.lkt.bo.SupplierGoodsBo;
import com.loukou.lkt.lkt.resp.RespDto;
import com.loukou.lkt.lkt.service.SupplierGoodsService;

@Controller
public class SupplierGoodsController {

	@Autowired
	private SupplierGoodsService supplierGoodsService;

	@RequestMapping(value = "/api/supplierGoods/getListData", method = RequestMethod.GET)
	@ResponseBody
	public RespDto<List<SupplierGoodsBo>> getListData(
			@RequestParam(value = "taosku", required = false, defaultValue = "") String taosku,
			@RequestParam(value = "bn", required = false, defaultValue = "") String bn,
			@RequestParam(value = "goodsName", required = false, defaultValue = "") String goodsName,
			@RequestParam(value = "supplierId", required = false, defaultValue = "-1") int supplierId) {
		RespDto<List<SupplierGoodsBo>> dto = supplierGoodsService.getList(supplierId, taosku, bn, goodsName);
		return dto;
	}
	

	@RequestMapping(value = "/api/supplierGoods/getGoodsPageList", method = RequestMethod.GET)
	@ResponseBody
	public RespDto<List<GoodsBo>> getGoodsPageList(
			@RequestParam(value = "taosku", required = false, defaultValue = "") String taosku,
			@RequestParam(value = "bn", required = false, defaultValue = "") String bn,
			@RequestParam(value = "goodsName", required = false, defaultValue = "") String goodsName,			
			@RequestParam(value = "pageIndex", required = false, defaultValue = "1") int pageIndex,
			@RequestParam(value = "pageNum", required = false, defaultValue = "10") int pageNum) {

		return supplierGoodsService.getGoodsPageList(taosku, bn, goodsName,pageIndex,pageNum);
	}

	@RequestMapping(value = "/api/supplierGoods/delete", method = RequestMethod.POST, consumes = "application/json")
	@ResponseBody
	public RespDto<Integer> delete(@RequestBody List<SupplierGoodsBo> supplierGoodsBo) {
		return supplierGoodsService.delete(supplierGoodsBo);
	}
	
	@RequestMapping(value = "/api/supplierGoods/addGoods", method = RequestMethod.POST, consumes = "application/json")
	@ResponseBody
	public RespDto<Integer> addGoods(@RequestBody List<GoodsBo> goodsSpecBoList) {
		return supplierGoodsService.addGoods(goodsSpecBoList);
	}

	@RequestMapping("/web/supplierGoods/index")
	public String index() {
		return "supplier/supplierGoods";
	}

	@RequestMapping("/web/supplierGoods/selectGoods")
	public String selectGoods() {
		return "supplier/selectGoods";
	}

}
